﻿<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <title>企业位置标点维护</title>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
            var currentMarker = null;

            function handlePointClick(event) {
                if (currentMarker == null) {
                    document.getElementById('lat').value = event.latLng.lat();
                    document.getElementById('lng').value = event.latLng.lng();

                    currentMarker = new google.maps.Marker({
                        position: new google.maps.LatLng(event.latLng.lat(), event.latLng.lng())
                    });
                    map.addOverlay(currentMarker);
                    dlg.show();
                }
            }

            function markerAddComplete() {
                var title = document.getElementById('title');
                currentMarker.setTitle(title.value);
                title.value = "";
                currentMarker = null;
                dlg.hide();
            }

            function cancel() {
                dlg.hide();
                currentMarker.setMap(null);
                currentMarker = null;
                return false;
            }
        </script>
        <style type="text/css">
            .cancel {
                color: #ff0000;
            }
        </style>
    </ui:define>
    <ui:define name="content">
        <h:form id="form" prependId="false">
            <p:growl id="messages" showDetail="true"/>
            <p:gmap id="gmap" center="36.00133452627246,119.443359375" zoom="10" type="ROADMAP"
                    style="width:900px;height:560px"
                    model="#{thMapAction.projectModel}" onPointClick="handlePointClick(event);" widgetVar="map">
                <p:ajax event="markerDrag" listener="#{thMapAction.onMarkerDrag}" update="messages"/>
                <p:ajax event="overlaySelect" listener="#{thMapAction.onMarkerSelect}" oncomplete="thAssetDLG.show()"
                        update="tabSum"/>
            </p:gmap>
            <p:dialog widgetVar="dlg" effect="FADE" effectDuration="0.5" close="false" fixedCenter="true">
                <h:panelGrid columns="2">
                    <h:outputLabel for="title" value="核算项目:"/>
                    <p:selectOneMenu id="title" value="#{thMapAction.title}" style="width: 145px;">
                        <f:selectItem itemLabel="" itemValue=""/>
                        <f:selectItems value="#{thMapAction.projectNameMaps}"/>
                    </p:selectOneMenu>
                    <f:facet name="footer">
                        <p:commandButton value="添加" actionListener="#{thMapAction.addMarker}" update="messages,gmap"
                                         oncomplete="markerAddComplete()"/>
                        <p:commandButton value="取消" onclick="return cancel()"/>
                    </f:facet>
                </h:panelGrid>
                <h:inputHidden id="lat" value="#{thMapAction.lat}"/>
                <h:inputHidden id="lng" value="#{thMapAction.lng}"/>
            </p:dialog>


            <p:dialog id="thAssetDLG" header="房产详情" widgetVar="thAssetDLG" showEffect="drop" hideEffect="drop">
                <p:dataTable id="tabSum" style="width:1100px;height: 550px;text-align: center;"
                             value="#{thMapAction.thAssetList}"
                             var="thAsset"
                             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             paginator="true"
                             paginatorPosition="bottom"
                             rows="20"
                             rowsPerPageTemplate="100,50,30,20,15"
                             emptyMessage="数据记录为空..."
                             rowStyleClass="#{thAssetAction.cancelled(thAsset.assetId) ? 'cancel' : ''}"
                        >

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="房产编号"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetId}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="纳税人识别号"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.taxpayerId}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="房产类型"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetClass}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="房产性质"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetType}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="房产地址"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetAddress}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="楼座号"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetBuilding}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="单元"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetCell}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="楼层"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetStory}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="房号"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetRoom}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="结构"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetMakeup}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="房型"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetKind}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="朝向"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetOrient}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="录入日期"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.inputDate}">
                            <f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" locale="cn"></f:convertDateTime>
                        </h:outputText>
                        <f:facet name="footer">
                            <h:outputText value="笔数：#{fn:length(thMapAction.thAssetList)}"/>
                        </f:facet>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="面积"/>
                        </f:facet>
                        <h:outputText value="#{thAsset.assetArea}"/>
                        <f:facet name="footer">
                            <h:commandLink>
                                <h:outputText value="导出数据"/>
                                <p:dataExporter type="xls" target="tabSum" fileName="houseDetail"/>
                            </h:commandLink>
                        </f:facet>
                    </p:column>
                </p:dataTable>
            </p:dialog>
        </h:form>
    </ui:define>
</ui:composition>